package com.chif.goingplus.service;

import com.chif.goingplus.dao.EmpMapper;
import com.chif.goingplus.pojo.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EmpServiceImpl implements EmpService{

    @Autowired
    private EmpMapper empMapper;

    @Override
    public int addEmp(Emp emp) {
        empMapper.addEmp(emp);
        return emp.getEid();
    }

    @Override
    public int deleteEmpById(int id) {
        return empMapper.deleteEmpById(id);
    }

    @Override
    public int updateEmp(Emp emp) {
        return empMapper.updateEmp(emp);
    }

    @Override
    public Emp queryEmpById(int id) {
        return empMapper.queryEmpById(id);
    }

    @Override
    public List<Emp> queryAllEmp() {
        return empMapper.queryAllEmp();
    }

    @Override
    public Emp queryEmpByName(String ename) {
        return empMapper.queryEmpByName(ename);
    }

    @Override
    public Emp queryEmpByUserName(String usernmae) {
        return empMapper.queryEmpByUserName(usernmae);
    }

    @Override
    public int updatePowerById(int eid,int power) {
        Map map = new HashMap<String,Integer>();
        map.put("eid",eid);
        map.put("power",power);
        return empMapper.updatePowerById(map);
    }
}
